package com.twt.survey.utils;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class scheduleTasks {
    @Scheduled(cron = "0 0 1 * * ?")
    public void expirationTokenMapClean() {
        JwtUtil.tokenMap.entrySet().stream()
                .filter(stringDateEntry -> stringDateEntry.getValue().before(new Date()))
                .forEach(stringDateEntry -> JwtUtil.tokenMap.remove(stringDateEntry.getKey()));
    }
}
